#ifndef __Include_GuiStudio_MainFrame_MainFrame_H__
#define __Include_GuiStudio_MainFrame_MainFrame_H__

#include <QtGui/QMainWindow>
#include "ui_mainframe.h"
#include "qundogroup.h"
#include "qundoview.h"

class DlgResourceList;
class DlgPreferences;
class DlgAbout;

enum enBrowserType
{
	enBT_Layout,
	enBT_Imageset,
};

#define RECENT_FILE_MAX 5

class MainFrame : public QMainWindow
{
	Q_OBJECT

public:
	MainFrame(QWidget *parent = 0, Qt::WFlags flags = 0);
	~MainFrame();

public slots:
	void GLInited();
	void EditTypeChanged(enSelectionEditType selEditType);
	void SelectEditor(int idx);
	void CanUndoChanged(bool canUndo);
	void FileLoaded(enFileType ftype,const QString &filename);
	void WindowEditModeChanged(WindowBoxer::enEditMode mode);
	void ClipboardChanged(bool hasCopied);

private slots:
	//-------- file --------
	void actFileNewLayout();
	void actFileNewWindow();
	void actFileNewImageset();
	void actFileNewImage();
	void actFileOpen();
	void actFileSave();
	void actFileSaveAs();
	void actFileSaveAll();
	void actFileClose();
	void actFileCloseAll();
	void actFileExit();

	//-------- eidt --------
	void actEditCopy();
	void actEditCut();
	void actEditPaste();
	void actEditDelete();
	void actEditAlignLeft();
	void actEditAlignHCenter();
	void actEditAlignRight();
	void actEditAlignTop();
	void actEditAlignVCenter();
	void actEditAlignBottom();
	void actEditAlignWidth();
	void actEditAlignHeight();
	void actEditAlignSize();
	void actEditClearSelections();

	//-------- layout --------
	void actLayoutActivate();
	void actLayoutSelectSkin();
	void actLayoutEditModeAbsolute();
	void actLayoutEditModeRelative();
	void actLayoutEditModeFreezed();

	//-------- imageset --------
	void actImagesetActivate();

	//-------- settings --------
	void actSettingsResourcePaths();
	void actSettingsPreferences();

	//-------- help --------
	void actHelpAbout();

	//-------- recent files --------
	void actOpenRecentLayout();
	void actClearRecentLayouts();
	void actOpenRecentImageset();
	void actClearRecentImagesets();

private:
	void contextMenuEvent(QContextMenuEvent *evt);

	enFileType GetFileType(enEditorType editortype);

	void CheckUndoStatus();
	void CheckDocOpenStatus();

	void ReadRecentFileConfig();
	void SaveRecentFileConfig();
	void MarkRecentFile(enFileType filetype,const QString &filename);
	void UpdateRecentFiles();

	Ui::MainFrameClass ui;

	DlgResourceList *m_pDlgResourceList;
	DlgPreferences *m_pDlgPreferences;
	DlgAbout *m_pDlgAbout;

	QUndoGroup *m_pUndoGroup;
	QAction *m_pUndoAct;
	QAction *m_pRedoAct;

	QMenu *m_pRightMouseMenu;

	QString m_srAppTitle;
	QString m_srAppTitleSuffix;

	QMenu *m_pRecentLayoutMenu;
	QStringList m_listRecentLayoutFiles;
	QAction *m_arRecentLayoutActions[RECENT_FILE_MAX];
	QAction *m_pActionClearRecentLayouts;

	QMenu *m_pRecentImagesetMenu;
	QStringList m_listRecentImagesetFiles;
	QAction *m_arRecentImagesetActions[RECENT_FILE_MAX];
	QAction *m_pActionClearRecentImagesets;

	QString m_srRecentFileCfg;
};

#endif //__Include_GuiStudio_MainFrame_MainFrame_H__
